package l2ft.gameserver.hwid;

import java.io.IOException;
import java.util.logging.Logger;

import l2ft.gameserver.Config;
import l2ft.gameserver.crypt.BlowfishEngine;

/**
 * @author FireMoon
 */
public class SmartGuard
{
	public static final Logger _log = Logger.getLogger(SmartGuard.class.getName());
	
	protected static byte[] _key = new byte[16];
	
	public static byte[] getKey(byte[] key)
	{
		byte[] bfkey = {5, 5, 17, 11, 22, 32, 9, 9, 1, 17, -1, -2, 44, 45, -28, -12}; //STATIC KEY
		
		try
		{
			BlowfishEngine bf = new BlowfishEngine();
			bf.init(true, bfkey);
			bf.processBlock(key, 0, _key, 0);
			bf.processBlock(key, 8, _key, 8);
		}
		catch (IOException e)
		{
			_log.warning("Incorrect Key!");
		}
		
		System.out.println("get key:"+_key);
		
		return _key;
	}
	
	public static boolean isSmartGuardEnabled()
	{
		if (Config.ALLOW_SMARTGUARD)
			return true;
		
		return false;
	}
	
	public static int getHWIDOption()
	{
		return Config.GET_CLIENT_HWID;
	}
}